/**
 * Copyright (c) 2012-2013 YunZhiSheng(Shanghai) Co.Ltd. All right reserved.
 * @FileName	: RomApp.java
 * @ProjectName	: vui_assistant
 * @PakageName	: cn.yunzhisheng.vui.assistant.oem
 * @Author		: Dancindream
 * @CreateDate	: 2013-9-9
 */
package com.zl.api;

import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.util.Log;

/**
 * @Module		: 隶属模块名
 * @Comments	: 描述
 * @Author		: Dancindream
 * @CreateDate	: 2013-9-9
 * @ModifiedBy	: Dancindream
 * @ModifiedDate: 2013-9-9
 * @Modified: 
 * 2013-9-9: 实现基本功能
 */
public class RomApp {
	public static final String TAG = "RomApp";
	public static final String TAG_2 = "RomApp_2";

	public static void lanchApp(Context context, String packageName, String className) {
		Log.d(TAG, "lanchApp packageName=" + packageName + "; className:" + className);
		if (context != null) {
			Intent intent = new Intent(Intent.ACTION_MAIN);
			intent.setClassName(packageName, className);
			//intent.setPackage(packageName);
			
			intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			context.startActivity(intent);
			Log.d(TAG_2,"packageName:" + packageName + "className:" + className);
		}
	}
	
	public static void uninstallApp(Context context, String packageName) {
		Log.d(TAG, "uninstallApp packageName=" + packageName);
		if (context != null) {
			Intent intent = new Intent(Intent.ACTION_DELETE, Uri.fromParts("package", packageName, null));
			intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			context.startActivity(intent);
		}
	}
	
	public static void exitApp(Context mContext, String packageName, String className) {

		if (packageName != null && !"".equals(packageName) && className != null && !"".equals(className)) {
			ActivityManager manager = (ActivityManager)mContext.getSystemService(Context.ACTIVITY_SERVICE);       
			manager.killBackgroundProcesses(packageName);


		} 
	}
}
